package com.ruoyi.project.catType.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.project.catType.domain.WmsCallTcar;
import com.ruoyi.project.catType.service.IWmsCallTcarService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 台车类型对应Controller
 * 
 * @author ruoyi
 * @date 2025-04-18
 */
@Controller
@RequestMapping("/carType/tcar")
public class WmsCallTcarController extends BaseController
{
    private String prefix = "carType/tcar";

    @Autowired
    private IWmsCallTcarService wmsCallTcarService;

    @GetMapping()
    public String tcar()
    {
        return prefix + "/tcar";
    }

    /**
     * 查询台车类型对应列表
     */
    @RequiresPermissions("carType:tcar:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(WmsCallTcar wmsCallTcar)
    {
        startPage();
        List<WmsCallTcar> list = wmsCallTcarService.selectWmsCallTcarList(wmsCallTcar);
        return getDataTable(list);
    }

    /**
     * 导出台车类型对应列表
     */
    @RequiresPermissions("carType:tcar:export")
    @Log(title = "台车类型对应", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(WmsCallTcar wmsCallTcar)
    {
        List<WmsCallTcar> list = wmsCallTcarService.selectWmsCallTcarList(wmsCallTcar);
        ExcelUtil<WmsCallTcar> util = new ExcelUtil<WmsCallTcar>(WmsCallTcar.class);
        return util.exportExcel(list, "台车类型对应数据");
    }

    /**
     * 新增台车类型对应
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存台车类型对应
     */
    @RequiresPermissions("carType:tcar:add")
    @Log(title = "台车类型对应", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(WmsCallTcar wmsCallTcar)
    {
        return toAjax(wmsCallTcarService.insertWmsCallTcar(wmsCallTcar));
    }

    /**
     * 修改台车类型对应
     */
    @RequiresPermissions("carType:tcar:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        WmsCallTcar wmsCallTcar = wmsCallTcarService.selectWmsCallTcarById(id);
        mmap.put("wmsCallTcar", wmsCallTcar);
        return prefix + "/edit";
    }

    /**
     * 修改保存台车类型对应
     */
    @RequiresPermissions("carType:tcar:edit")
    @Log(title = "台车类型对应", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(WmsCallTcar wmsCallTcar)
    {
        return toAjax(wmsCallTcarService.updateWmsCallTcar(wmsCallTcar));
    }

    /**
     * 删除台车类型对应
     */
    @RequiresPermissions("carType:tcar:remove")
    @Log(title = "台车类型对应", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(wmsCallTcarService.deleteWmsCallTcarByIds(ids));
    }
}
